﻿using System;
using Microsoft.Xna.Framework;

namespace Serious
{
    public class CylinderControllerBasic
    {
        public readonly Single move_speed;
        public readonly Single turn_speed; // degrees per frame
        public readonly Single jump_mag;

        public Cylinder subject;

        public CylinderControllerBasic(Cylinder subject)
        {
            this.subject = subject;

            move_speed = 0.275f;
            turn_speed = 1.5f;
            jump_mag = 0.7f;
        }

        public void StartTurningLeft ()
        {
            subject.angle_delta = turn_speed;
        }
        public void StartTurningRight ()
        {
            subject.angle_delta = -turn_speed;
        }
        public void StopTurning ()
        {
            subject.angle_delta = 0.0f;
        }

        /**
         * relative to the angle that cylinder is facing
         * */
        public void StartMovingInDirection (Vector2 dir)
        {
            subject.move_vector = dir * move_speed;
        }
        public void StopMoving ()
        {
            subject.move_vector = Vector2.Zero;
        }

        public void Jump ()
        {
            //if (!subject.on_floor) return;
            // hax hax hax hax hax hax!
            // adding Cylinder.gravity is a terrible hack
            // but it works
            subject.velocity.Z = jump_mag + Cylinder.gravity;
            subject.on_floor = false;
        }

        public void FastFall()
        {
            subject.velocity.Z = -5.0f;
        }
    }
}
